package com.zhq.blog.core.domain.game.support;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.zhq.blog.core.domain.game.support.AutoBetBase.RunningState;

/**
 * @title:AutoBetRepository.java
 * @package com.zhq.blog.core.domain.game.support
 * @author 张恒强
 * @date 2014年12月26日 下午2:20:34
 * @version V1.0
 */
public interface AutoBetRepository extends AutoBetBaseRepository<AutoBet>{
	
	
	/**
	 * 找到某游戏当前正在运行的  开始期数小于投注期数的自动投注
	 * @return
	 */
	@Query("select a from AutoBet a where a.deleted = 0 and a.gameId = :gameId and a.startBetPeriod <= :period and a.state = :state")
	List<AutoBet> find_by_all_running(@Param("gameId")long gameId,@Param("period") long period,@Param("state") RunningState state);

	@Query("select a from AutoBet a where a.deleted = 0 and a.gameId = :gameId and a.userId = :userId ")
	List<AutoBet> find_by_game_user(@Param("gameId") long gameId,@Param("userId")long userId);
}
